#ifndef __INNER_MODS_ARCH_H_
#define __INNER_MODS_ARCH_H_

#include "typedef.h"

#if defined(_2TASK)
StackPointer arch_build_stack_frame(StackPointer sp, address entry, object arg);
#endif

#if defined(_2SCHED)
int arch_save_curr_context(address to_save_old_sp);
void arch_switch_to_task(StackPointer new_sp);
void arch_set_tick_sched(executable sched_func);
int arch_actual_core_num();
#endif

#if defined(_2KERNEL)
boolean arch_compare_and_swap(address addr, word old_value, word new_value);
int arch_get_cpuid();
word arch_disable_local_irq();
void arch_enable_local_irq(word status);
#endif

#if defined(_2IRQM)
void arch_enable_int(int id, int cpu);
void arch_set_irq_handler(executable handler);
#endif

#if defined(_2TIMER)
void arch_set_ttimer_timeout(executable do_timeout);
#endif


#if defined(_2SCHED) || defined(_2MISC)
boolean arch_is_core_online(int core);
#endif

#define FORBIT_LOCAL_INT(save) word save = arch_disable_local_irq()
#define RESUME_LOCAL_INT(save) arch_enable_local_irq(save)
#define WINK_LOCAL_INT(save)             \
    do                                   \
    {                                    \
        arch_enable_local_irq(save);     \
        save = arch_disable_local_irq(); \
    } while (0);

#endif//__INNER_MODS_ARCH_H_